from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import numpy as np
import cv2 as cv
import sys
from camerapage import Ui_Form

class CameraPageWindow(QWidget,Ui_Form):
    def __init__(self, parent=None):
        super(CameraPageWindow, self).__init__(parent)

        self.setupUi(self)

        self.show()
        self.cap = cv.VideoCapture(0)
        self.timer_camera = QTimer()
        self.timer_camera.timeout.connect(self.show1)
        self.timer_camera.start(60)

    def show1(self):
        flag,image = self.cap.read()
        show = cv.resize(image, (480, 320))
        show = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
        showImage = QImage(show.data, show.shape[1], show.shape[0], QImage.Format_RGB888)
        self.cameraLabel.setPixmap(QPixmap.fromImage(showImage))




# a=CameraPageWindow()
app = QApplication(sys.argv)
a=CameraPageWindow()
sys.exit(app.exec_())